import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import federation from "@originjs/vite-plugin-federation"
import Components from 'unplugin-vue-components/vite'
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
import dynamicImportVars from '@rollup/plugin-dynamic-import-vars'
// import ExternalTemplateRemotesPlugin from 'external-remotes-plugin'
// const ExternalTemplateRemotesPlugin = require('external-remotes-plugin')
// const url = ['remote_app1/description']

export default defineConfig({
  plugins: [
    federation({
      name: 'host-app',
      remotes: {
        remote_app1: "http://localhost:5174/dist/assets/remoteEntry.js",
        remote_app2: "http://localhost:5175/dist/assets/remoteEntry.js",
      },
      shared: ['vue', 'ant-design-vue']
    }),
    // new ExternalTemplateRemotesPlugin(),
    dynamicImportVars({ include: ['./component/*.vue'] }),
    // Components({
    //   dts: "src/components.d.ts",
    //   dirs: ['remote_app1/description'], // 配置需要默认导入的自定义组件文件夹，该文件夹下的所有组件都会自动 import
    //   resolvers: [AntDesignVueResolver({ importStyle: false, resolveIcons: true })]
    // }),
    vue()],
})
